package services

import (
	"app/common/constant"
	"context"
	"encoding/json"
)

func UserInfo[T any](ctx context.Context) (user T) {
	bytes, ok := ctx.Value(constant.CONTENT_USER_KEY).([]byte)
	if !ok {
		return
	}
	json.Unmarshal(bytes, &user)
	return
}
